From b47ff72ebc626180fc14459a66fd06e64fedcdb2 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 12 Nov 2017 06:19:00 +0100 Subject: [PATCH] progresstracker: Don't hand out NaN When the duration is set to 0, clamp it to 1us. This way we're almost correct: We should really instantly finish, but we don't. But we do respect the delay. Doing this properly would require some refactoring of how the progress tracker actually maintains progress, and this is just a quick fix. --- gtk/gtkprogresstracker.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk/gtkprogresstracker.c b/gtk/gtkprogresstracker.c index 81cca35d19..0ddcbfbe4c 100644 --- a/gtk/gtkprogresstracker.c +++ b/gtk/gtkprogresstracker.c @@ -82,7 +82,7 @@ gtk_progress_tracker_start (GtkProgressTracker *tracker, tracker->is_running = TRUE; tracker->last_frame_time = 0; tracker->duration = duration; - tracker->iteration = - delay / (gdouble) duration; + tracker->iteration = - delay / (gdouble) MAX (duration, 1); tracker->iteration_count = iteration_count; } @@ -108,7 +108,7 @@ gtk_progress_tracker_finish (GtkProgressTracker *tracker) **/ void gtk_progress_tracker_advance_frame (GtkProgressTracker *tracker, - guint64 frame_time) + guint64 frame_time) { gdouble delta; @@ -127,7 +127,7 @@ gtk_progress_tracker_advance_frame (GtkProgressTracker *tracker, return; } - delta = (frame_time - tracker->last_frame_time) / gtk_slowdown / tracker->duration; + delta = (frame_time - tracker->last_frame_time) / gtk_slowdown / MAX (tracker->duration, 1); tracker->last_frame_time = frame_time; tracker->iteration += delta; } -- 2.30.2